%the revisible part are K,N,RNK, R(s), sigma(s), y0, tspan
clear all
% index J for X
alphaK=50; alphas=[zeros(1,alphaK);eye(alphaK)];
fname='alphas'; save(fname,'alphas');
% index J for sigma
betaK=50;  betas = [zeros(1,betaK);eye(betaK)];
fname='betas';  save(fname,'betas');
% time T
T = 1/2;
% construct orthogoal basis in L2[0,t]
orthbasis(T);
% initial condition for X
betarow=size(betas,1); alpharow=size(alphas,1);
row=alpharow*betarow;
X0=zeros(row,1);   X0(1)=0;
% initial condition for sigma
sig0=zeros(size(betas,1),1); sig0(1)=1;
% time mesh 
num=50;
tspan = linspace(0,T,num+1);
% ms' value
msvalue(num)
% solver of sigma
options = odeset('AbsTol',1e-12,'RelTol',1e-6);
% % % %parameters of ou
a=1;m=1;b=1; para=[a,m,b,num];
% % % disp('sloving sigma')
% % % tic
% % % [time,sig] = ode45(@randomou,tspan,sig0,[],para);
% % % toc
sig=zeros(num+1,betaK+1);
sig(:,1)=1;
fname='sigma';
save(fname,'sig');
% solver of X
disp('sloving X')
tic
[time,X]   = ode45(@randomasset,tspan,X0,[],num);
toc
% error
%meanerr(time',y,R,sig,y0,Y/numpath)
%varerr(time',sig,a,m,b,sig0(1),sig.*sig)
varX(time',X,a,m,b,X0(1),X.*X)


